﻿@page
@{ Layout = "_Layout"; }

<el-form v-on:submit.native.prevent :inline="true">
  <el-form-item label="栏目筛选">
    <el-input v-model="filterText" size="mini" placeholder="请输入栏目名称/栏目Id"></el-input>
  </el-form-item>
</el-form>

<el-row :gutter="12">
  <el-col :span="12">
    <el-card>
      <div slot="header" class="clearfix">
        <span>批量替换内容栏目</span>
      </div>

      <el-tree
        ref="tree"
        :data="channels"
        :default-expanded-keys="expandedChannelIds"
        :default-checked-keys="checkedChannelIds"
        node-key="value"
        show-checkbox
        check-on-click-node
        check-strictly
        highlight-current
        class="tree"
        :filter-node-method="filterNode"
        v-on:check-change="handleCheckChange">
        <div slot-scope="{ node, data }">
          <el-link :underline="false" :href="getChannelUrl(data)" v-on:click.stop.native target="_blank"><i class="el-icon-link"></i></el-link>
          {{ data.label }} ({{ data.count }})
          <el-tag size="mini" v-if="data.indexName">
            {{ data.indexName }}
          </el-tag>
        </div>
      </el-tree>
    </el-card>
  </el-col>
  <el-col :span="12">
    <el-card>
      <div slot="header" class="clearfix">
        <span>替换规则</span>
      </div>

      <el-form v-on:submit.native.prevent ref="form" :model="form" size="small" label-position="top">
        <el-form-item label="替换字段">
          <el-checkbox v-for="attribute in attributes" :key="attribute.value" v-model="attribute.selected" :label="attribute.value">{{ attribute.label }}</el-checkbox>
        </el-form-item>
        <el-form-item label="查找文字" prop="replace" :rules="{ required: true, message: '请输入查找文字' }">
          <el-input autosize :autosize="{ minRows: 2, maxRows: 4}" type="textarea" v-model="form.replace"></el-input>
        </el-form-item>
        <el-form-item label="查找设置">
          <el-checkbox label="区分大小写" :disabled="form.isRegex" v-model="form.isCaseSensitive"></el-checkbox>
          <el-checkbox label="使用正则表达式" :disabled="form.isCaseSensitive" v-model="form.isRegex"></el-checkbox>
          <el-checkbox label="包含下级栏目" v-model="form.isDescendant"></el-checkbox>
          
        </el-form-item>
        <el-form-item label="替换文字" prop="to">
          <el-input autosize :autosize="{ minRows: 2, maxRows: 4}" type="textarea" v-model="form.to"></el-input>
        </el-form-item>
      </el-form>

      <div style="margin: 10px 0"></div>
      <el-divider></el-divider>
      <div style="margin: 10px 0"></div>

      <el-tooltip class="item" effect="dark" placement="top">
        <div slot="content" style="text-align: center">批量替换<br/>Ctrl+回车</div>
        <el-button v-on:click="btnReplaceClick" :disabled="channelIds.length === 0" type="primary" size="medium">
          批量替换
        </el-button>
      </el-tooltip>

    </el-card>
  </el-col>
</el-row>

@section Scripts{
<script src="/sitefiles/assets/js/admin/cms/contentsReplace.js" type="text/javascript"></script>
}
